<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/account/css/pintuer.css">
<link rel="stylesheet" href="/account/css/admin.css">
<script type="text/javascript" src="/account/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="/account/js/vue.js"></script>
	<link rel="stylesheet" href="/account/layui/layui/css/layui.css">
	<script type="text/javascript" src="/account/layui/layui/layui.js"></script>
</head>
<body>
	<div class="panel admin-panel" id="app">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>增加商品</strong>
		</div>
		<div class="body-content">
			<form  id="form" class="form-x" >
				<div class="form-group">
					<div class="label">
						<label>流水单号：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50"   id="accountSerialNum" v-if="account!=null" v-model="account.accountSerialNum"/>
					</div>
				</div>
				
					<div class="form-group">
					<div class="label">
						<label>总金额：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="accountTotal"  id="accountTotal" v-if="account!=null"  v-model="account.accountTotal"/>

					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>项目id：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="" name="accountProjectId"  id="accountProjectId"  v-if="account!=null" v-model="account.accountProjectId"/>
						
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>工序号：</label>
					</div>
					<div class="field">
						<select  class="input" id="accountOperationNum"
								 style="width: 200px; line-height: 17px;">
							<option value=-1>请选择工序号</option>
							<option value=0 >定金</option>
							<option value=1 >施工一阶段</option>
							<option value=2 >施工二阶段</option>
							<option value=3 >施工三阶段</option>
							<option value=4>施工四阶段</option>
							<option value=5>施工五阶段</option>

						</select>
					</div>
					</div>
				<div class="form-group">
					<div class="label">
						<label>支付状态：</label>
					</div>
					<div class="field">
						<select  class="input" id="accountRemark"
								 style="width: 200px; line-height: 17px;">
							<option value=0 >请选择支付状态</option>
							<option value=1>已支付</option>
							<option value=2 >未支付</option>
						</select>
					</div>
				</div>
					
				<div v-for="(item,i) in pics"><img :src="item.accountingProofOfAddress" width="100px"><button class="layui-btn" type="button" @click="check(item.accountingProofOfAddress)">查看</button><button class="layui-btn layui-btn-danger" type="button" @click="update(item.accountingVouchersId)">更改</button></div>
					<br>
				<div class="form-group">

					<div class="field">
						<button class="button bg-main icon-check-square-o" type="button" onclick="updateAccount()">
							提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>

<script type="text/javascript">
var id=location.href.split("?")[1].split("=")[1];

var _this;
var app=new Vue({
	el:"#app",
	data:{
		account:null,
		pics:null
	},
	created:function(){
		_this=this;
		this.selectById();
	},
	methods:{

		selectById:function(){
			$.ajax({
				url:"/account/account/selectById",
				type:"get",
				data:{"id":id},
				dataType:"json",
				success:function(data){
					_this.account=data.obj;
					_this.pics=data.list;
				}
			})
		},
		check:function (i) {
			location.href=i;
		},
		update:function (o) {
			layui.use('layer', function(){
				var layer = layui.layer;
				layer.open({
					type: 2,
					title: '更新凭证',
					shadeClose: true,
					shade: 0.5,
					area: ['400px', '100%'],
					content:' updatepic.html?id='+o ,
				});
			});

		}
	}
});
	function updateAccount() {
		if (confirm("确定更新吗？")) {
			$.ajax({
				url: "/account/account/update",
				type: "post",
				data: {
					accountId:id,
					accountSerialNum: $("#accountSerialNum").val(),
					accountTotal: $("#accountTotal").val(),
					accountProjectId: $("#accountProjectId").val(),
					accountOperationNum: $("#accountOperationNum").val(),
					accountRemark: $("#accountRemark").val()
				},
				dataType: "json",
				success: function (data) {
					alert("更新成功");
					location.href = "/account/account.html";
				},
				error: function (error) {
					alert("更新失败");
					location.href = "/account/account.html";
				}
			})
		}
	}

</script>
</html>

